<?php
	$query = "select * from `radio_dj` where `userid`='$id'";
	$result = mysql_query($query);
	if (mysql_num_rows($result)) {
		$djprofile = mysql_fetch_array($result);
		$dj_id = $djprofile['id'];

		if ($_REQUEST['delete']){
			$show_id = escapestr($_REQUEST['delete']);
			$query 	= "delete from `radio_extra` where `id`='$show_id' and `dj`='$dj_id'";
			$result = mysql_query($query);
			if ($result) {
				$SITE_MIDDLE .= FormatElement (GetLangString($lang,"txt_showdeleted"),GetLangString($lang,"msg_showdeleted"));  
			} else {
				$SITE_MIDDLE .= FormatElement (GetLangString($lang,"txt_error"),GetLangString($lang,"msg_dberror").$query);  
			}
		}
		if ($_REQUEST['addshow']){
			$date 	= escapestr($_REQUEST['year'].$_REQUEST['month'].$_REQUEST['day']);


			$start =  escapestr($_REQUEST['start']);
			$stop =  escapestr($_REQUEST['stop']);
			
			$query 	= "insert into `radio_extra` (`dj`,`date`,`start`,`stop`) values ('$dj_id','$date','$start','$stop')";
			$result = mysql_query($query);
			if ($result) {
				$SITE_MIDDLE .= FormatElement (GetLangString($lang,"txt_showadded"),GetLangString($lang,"msg_showadded"));  
			} else {
				$SITE_MIDDLE .= FormatElement (GetLangString($lang,"txt_error"),GetLangString($lang,"msg_dberror").$query);  
			}
		}
		$query 	= "select * from `radio_extra` where `dj`='$dj_id' order by `date` asc";
		$result = mysql_query($query);
		$txt = "<center><table border=\"1\" width=\"90%\"><tr>
			<td width=\"25%\">".GetLangString($lang,"txt_day")."</td><td width=\"25%\">".GetLangString($lang,"txt_start")."</td><td width=\"25%\">".GetLangString($lang,"txt_stop")."</td><td width=\"25%\"></td></tr>";
		while ($show = mysql_fetch_array($result)) {
			$year 	= substr($show['date'],0,4);
			$month  = substr($show['date'],4,2);
			$day 		=	substr($show['date'],6,2);
			$date   = "$day - $month - $year";
			$start 	= $show['start']; 
			$stop 	= $show['stop'];
			$showid = $show['id'];
			$delete = "<a href=\"/index.php?do=djextra&delete=$showid\">".GetLangString($lang,"txt_delete")."</a>"; 
			$txt .= "<tr><td>$date</td><td>$start</td><td>$stop</td><td>$delete</td></tr>";
		}
		$txt .= "</table></center>";
		$SITE_MIDDLE .= FormatElement(GetLangString($lang,"txt_yourextrashows"),$txt); 
		$addform = "<form action=\"/index.php?do=djextra\" method=\"post\">";
		$datefrm = "<center><table style =\"padding: 0\" border=\"0\"><tr><td width=\"33%\">".
		FormatSmallElement( GetLangString ($lang, "txt_day") , "<input value=\"".date('d')."\" name=\"day\" maxlenght=\"2\">").
		"</td><td width=\"33%\">".
		FormatSmallElement( GetLangString ($lang, "txt_month") , "<input value=\"".date('m')."\" name=\"month\" maxlenght=\"2\">").
		"</td><td width=\"33%\">".
		FormatSmallElement( GetLangString ($lang, "txt_year") , "<input value=\"".date('Y')."\"  name=\"year\" maxlenght=\"4\">").
		"</td></tr></table></center>";
		$addform .= FormatSmallElement(GetLangString($lang,"txt_date"),$datefrm);
		$addform .= FormatSmallElement(GetLangString($lang,"txt_start"),"<input name=\"start\" type=\"text\">");
		$addform .= FormatSmallElement(GetLangString($lang,"txt_stop"), "<input name=\"stop\" type=\"text\">");
		$addform .= "<input name=\"addshow\" value=\"".GetLangString($lang,"txt_save")."\"type=\"submit\">";

		$SITE_MIDDLE .= FormatElement (GetLangString( $lang, "txt_addshow") ,$addform ) ; 

		


	}else {
		$SITE_MIDDLE .= FormatElement(GetLangString($lang,"txt_error"),GetLangString($lang,"msg_nodjerror"));
	} 

?>
